//
// Copyright (c) 2024 BPer
//

#include <bperstream/BPerStream.h>

#include "BPerStreamRtc.h"


void bPer_create_stream(int32_t mediaServer,int32_t transType,BPerStreamHandle* streamHandle,BPerStreamConfig* streamconfig,BPerAVInfo* avinfo) {
	if(streamHandle==NULL) return;
	if(streamHandle->context==NULL) streamHandle->context=(BPerStreamContext*)bPer_calloc(sizeof(BPerStreamContext),1);
	BPerStreamContext* context=streamHandle->context;

	bPer_memcpy(&context->streamconfig,streamconfig,sizeof(BPerStreamConfig));

	context->avinfo=avinfo;


	context->streamInit = 0;
	context->audioStream=0;
	context->videoStream=0;
	context->uid=streamconfig->uid;
	context->netState = 1;
	context->transtype=transType;
	context->mediaServer=mediaServer;
	bPer_create_stream_rtc(streamHandle);

}

void bPer_destroy_stream(BPerStreamHandle* stream) {
	bPer_destroy_stream_rtc(stream);
	stream->context->avinfo=NULL;
	bPer_free(stream->context);
}
